package hu.vpszd.services.impl

import hu.vpszd.entities.Role
import hu.vpszd.services.RoleService
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

@Repository("roleService")
@Transactional
class RoleServiceImpl extends BaseServiceImpl<Role> implements RoleService  {
	@Override
	Role getUserRole() {
		List<Role> roles = super.findAll(Role.class)
		def userRole = roles.find() { it.name = 'ROLE_USER' }
		return userRole
	}
	
	@Override
	Role getReferensRole() {
		List<Role> roles = super.findAll(Role.class)
		def referensRole = roles.find() { it.name = 'ROLE_REFERENS' }
		return referensRole
	}
	
	@Override
	Role getBiraloRole() {
		List<Role> roles = super.findAll(Role.class)
		def biraloRole = roles.find() { it.name = 'ROLE_BIRALO' }
		return biraloRole
	}

	@Override
	List<Role> findAll() {
		findAll(Role.class)
	}
}
